package com.demo.spring.bussness;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.wendellup.entity.IStudentDAO;
import com.wendellup.entity.Student;
import com.wendellup.entity.StudentDAOImpl;

@Service
public class Bdo {
	
	private IStudentDAO iStudentDAO = null;



	public void out(){
		iStudentDAO = new StudentDAOImpl();
		System.out.println("ddd");
		Student student = new Student();
		student.setName("wendellup");
		student.setPassword("xxx");
		student.setBirthday(new Date());
		student.setCreateTime(new Date());
		int key;
		try {
			key = iStudentDAO.addStudent(student);
			System.out.println(key);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	

	public void setUp(){
		iStudentDAO = new StudentDAOImpl();
	}
	

	public void testQueryAllStudent() throws Exception{
		List<Student> studentList = iStudentDAO.queryAllStudent();
		for(Student stu : studentList){
			System.out.println(stu);
		}
	}

	public void testInsertStudent()throws Exception{
		Student student = new Student();
		student.setName("wendellup");
		student.setPassword("xxx");
		student.setBirthday(new Date());
		student.setCreateTime(new Date());
		int key = iStudentDAO.addStudent(student);
		System.out.println(key);
	}
}


